package com.woniuxy.consumer.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author yellow Doctor
 * @date 2025-03-27
 * @desc 蜗牛创想：www.woniuxy.com
 */
@Component
public class DeadListener {

    // Channel  连接MQ的 通道
    @RabbitListener(queues = "dlx.queue")
    public void handle(String msg,Channel channel,Message message) throws IOException {
        //消息的属性对象
//        MessageProperties properties = message.getMessageProperties();
//        //消息的唯一标识
//        long deliveryTag = properties.getDeliveryTag();

        System.out.println("我是死信消费者 ===> " + msg);
//
//        //手动应答 (ack  应答完毕后 queue中的消息会删除 )
//        channel.basicAck(deliveryTag, false);
    }

}
